home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / overview / dtscpluslibrary / sources / keymap.cp < prev    next >
Encoding:
Text File  |  2000-06-23  |  2.4 KB  |  104 lines

  1. /*
  2.     File:        KeyMap.cp
  3.  
  4.     Contains:    TKeyMap is a KeyMap utility class.
  5.                   TKeyMap.cp contains the member functions for the TKeyMap class.
  6.  
  7.     Written by: Kent Sandvik    
  8.  
  9.     Copyright:    Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.                 You may incorporate this Apple sample source code into your program(s) without
  12.                 restriction. This Apple sample source code has been provided "AS IS" and the
  13.                 responsibility for its operation is yours. You are not permitted to redistribute
  14.                 this Apple sample source code as "Apple sample source code" after having made
  15.                 changes. If you're going to re-distribute the source, we require that you make
  16.                 it clear in the source that the code was descended from Apple sample source
  17.                 code, but that you've made changes.
  18.  
  19.     Change History (most recent first):
  20.                 8/18/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  21.                 
  22.  
  23. */
  24. #ifndef _KEYMAP_
  25. #include "KeyMap.h"
  26. #endif
  27.  
  28.  
  29. // _________________________________________________________________________________________________________ //
  30. // TProcess class member function implementations
  31.  
  32. //    CONSTRUCTORS & DESTRUCTORS
  33.  
  34. #pragma segment KeyMap
  35. TKeyMap::TKeyMap()
  36. // Main constructor, empty for the time being.
  37. {
  38. }
  39.  
  40.  
  41. #pragma segment KeyMap
  42. TKeyMap::~TKeyMap()
  43. // Main destructor, empty for the time being.
  44. {
  45. }
  46.  
  47.  
  48. //     MAIN INTERFACES
  49. #pragma segment KeyMap
  50. Boolean TKeyMap::OptionKeyDown()
  51. // Return true if option key is down.
  52. {
  53.     ::GetKeys(fKeyMap);                            // get info
  54.     if (fKeyMap[1] & 4)
  55.         return true;
  56.     else
  57.         return false;
  58. }
  59.  
  60. #pragma segment KeyMap
  61. Boolean TKeyMap::CommandKeyDown()
  62. // Return true if command (Apple) key is down.
  63. {
  64.     ::GetKeys(fKeyMap);                            // get info
  65.     if (fKeyMap[1] & 0x8000)
  66.         return true;
  67.     else
  68.         return false;
  69. }
  70.  
  71.  
  72. #pragma segment KeyMap
  73. Boolean TKeyMap::ShiftKeyDown()
  74. // Return true if shift key is down.
  75. {
  76.     ::GetKeys(fKeyMap);                            // get info
  77.     if (fKeyMap[1] & 1)
  78.         return true;
  79.     else
  80.         return false;
  81. }
  82.  
  83.  
  84. // Fast macro for testing key codes.
  85. #define KeyCode(x,y) (BitTst(&(x), (y) ^ 0x07))
  86.  
  87.  
  88. #pragma segment KeyMap
  89. Boolean TKeyMap::IsKeyDown(unsigned short key)
  90. // Return true if key defined is down.
  91. {
  92.     ::GetKeys(fKeyMap);                            // get info
  93.     return (KeyCode(fKeyMap, key));
  94. }
  95.  
  96.  
  97. // _________________________________________________________________________________________________________ //
  98.  
  99.  
  100. /*    Change History (most recent last):
  101.   No        Init.    Date        Comment
  102.   1            khs        9/20/92        New file
  103. */
  104.